<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>会员中心-一览网</title>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/member.css">
    <script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
    <script type="text/javascript" src="js/layui/layui.all.js"></script>
</head>
<body>
<form id="add_invoice_form" action="http://www.buysellchem.com/member/account/create_invoice" accept-charset="UTF-8" method="post">
    <input type="hidden" name="_token" value="uPm8czm4d7Fg6QzZBbMaKawSKydIPC3UOk0MmSZB">
    <input type="hidden" name="method" id="invoice_method" value="create" />
    <input class="hidden" type="hidden" name="invoice[id]" id="edit_invoice_id" />
    <table class="kqy_table">
        <tbody>
        <tr>
            <td colspan="4" align="left"  style="border-bottom: 1px solid #d4dede; padding: 10px 0px; color: #1874ac; font-weight: bold;">发票信息</td>
        </tr>
        <tr>
            <td class="t1"><span class="red mr10">*</span>发票类型</td>
            <td>
                <select class="form_select" name="invoice[category]" id="invoice_category" tabindex="-1">
                    <option value="1">增值税发票(13%)</option>
                    <option value="2">增值税发票(普通)</option>
                </select>
            </td>
            <td class="t1"><span class="red mr10">*</span>公司名称</td>
            <td><input type="text" class="form_input wd300" id="invoice_company_name" value="" name="invoice[company_name]" placeholder="请输入您的公司名称"></td>
        </tr>
        <tr>
            <td class="t1"><span class="red mr10">*</span>税务登记号</td>
            <td>
                <input type="text" class="form_input wd300" id="invoice_tax_no" name="invoice[tax_no]" placeholder="请输入您的税务登记号">
            </td>
            <td class="t1"><span class="red mr10">*</span>电话</td>
            <td>
                <input type="text"  class="form_input wd300" id="invoice_mobile" name="invoice[mobile]" placeholder="请输入您的电话">
            </td>
        </tr>
        <tr>
            <td class="t1"><span class="red mr10">*</span>传真</td>
            <td>
                <input type="text" class="form_input wd300" id="invoice_fax" name="invoice[fax]" placeholder="请输入您的传真">
            </td>
            <td class="t1"><span class="red mr10">*</span>开户银行</td>
            <td>
                <input type="text" class="form_input wd300" id="invoice_bank" name="invoice[bank]" placeholder="请输入您的开户银行">
            </td>
        </tr>
        <tr>
            <td class="t1"><span class="red mr10">*</span>银行账户</td>
            <td colspan="3">
                <input type="text" class="form_input wd300" id="invoice_account_no" name="invoice[account_no]" placeholder="请输入您的银行账户">
            </td>
        </tr>
        <tr>
            <td class="t1"><span class="red mr10">*</span>公司地址</td>
            <td colspan="3">
                <input type="text" class="form_input wd500" id="invoice_company_address" name="invoice[company_address]" placeholder="请输入您的公司地址">
            </td>
        </tr>
        <tr>
            <td colspan="4" align="left" style="border-bottom: 1px solid #d4dede; padding: 10px 0px; color: #1874ac; font-weight: bold;">接收信息</td>
        </tr>
        <tr>
            <td class="t1"><span class="red mr10">*</span>收票人</td>
            <td>
                <input type="text" class="form_input wd300" id="invoice_delivery_contact" name="invoice[delivery_contact]" placeholder="请输入您的收票人">
            </td>
            <td class="t1"><span class="red mr10">*</span>联系电话</td>
            <td>
                <input type="text"  class="form_input wd300" id="invoice_delivery_mobile" name="invoice[delivery_mobile]" placeholder="请输入您的联系电话">
            </td>
        </tr>
        <tr>
            <td class="t1"><span class="red mr10">*</span>收票地址</td>
            <td colspan="3">
                <input type="text" class="form_input wd500" id="invoice_delivery_address" name="invoice[delivery_address]" placeholder="请输入您的收票地址">
            </td>
        </tr>
        <tr>
            <td colspan="4" align="center"><button class="submit_btn wdp50" type="button" onclick="javascript:void(0);" id="btn_save_invoice">确认</button></td>
        </tr>
        </tbody>
    </table>
</form>
<script  type="text/javascript">
    $("#btn_save_invoice").click(function(){

        var invoice_category = $("#invoice_category").val();
        var invoice_company_name = $("#invoice_company_name").val();
        var invoice_tax_no = $("#invoice_tax_no").val();
        var invoice_mobile = $("#invoice_mobile").val();
        var invoice_company_address = $("#invoice_company_address").val();
        var invoice_bank = $("#invoice_bank").val();
        var invoice_account_no = $("#invoice_account_no").val();
        var invoice_delivery_address = $("#invoice_delivery_address").val();
        var invoice_delivery_contact = $("#invoice_delivery_contact").val();
        var invoice_delivery_mobile = $("#invoice_delivery_mobile").val();
        var invoice_method= $("#invoice_method").val();
        var edit_invoice_id= $("#edit_invoice_id").val();

        if($.trim(invoice_company_name)==''){
            layer.alert('请输入公司名称!',{
                skin: 'layui-layer-lan',
                anim: 4
            });
            $("#invoice_company_name").focus();
            return false;
        }

        if($.trim(invoice_tax_no)==''){
            layer.alert('请输入税务登记号!',{
                skin: 'layui-layer-lan',
                anim: 4
            });
            return false;
        }
        if($.trim(invoice_mobile)=='' && invoice_category== 1){
            layer.alert('请输入电话!',{
                skin: 'layui-layer-lan',
                anim: 4
            });
            return false;
        }
        if($.trim(invoice_bank)=='' && invoice_category== 1){
            layer.alert('请输入开户行!',{
                skin: 'layui-layer-lan',
                anim: 4
            });
            return false;
        }
        if($.trim(invoice_account_no)=='' && invoice_category== 1){
            layer.alert('请输入银行账户!',{
                skin: 'layui-layer-lan',
                anim: 4
            });
            return false;
        }
        if($.trim(invoice_company_address)=='' && invoice_category== 1){
            layer.alert('请输入公司地址!',{
                skin: 'layui-layer-lan',
                anim: 4
            });
            return false;
        }
        if($.trim(invoice_delivery_contact)==''){
            layer.alert('请输入收票人!',{
                skin: 'layui-layer-lan',
                anim: 4
            });
            return false;
        }
        if($.trim(invoice_delivery_mobile)==''){
            layer.alert('请输入收票人联系电话!',{
                skin: 'layui-layer-lan',
                anim: 4
            });
            return false;
        }
        if($.trim(invoice_delivery_address)==''){
            layer.alert('请输入收票地址!',{
                skin: 'layui-layer-lan',
                anim: 4
            });
            return false;
        }


        $.ajax({
            url: $("#add_invoice_form").attr('action'),
            data: $("#add_invoice_form").serializeArray(),
            type: 'post',
            cache: false,
            dataType: 'json',
            success: function (data) {
                layer.alert(data.msg,{
                    skin: 'layui-layer-lan',
                    anim: 4
                },function () {
                    window.location.href="http://www.buysellchem.com/member/account/invoice";
                });
            },
            error: function () {
                layer.msg('系统异常，请联系客服人员！', {icon: 2});
            }
        });

    });
</script>
</body>
</html>